package org.esjsoftware.v2m.rim.ui;

import net.rim.device.api.system.Application;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiEngine;

public class UIManager {
	static Screen current;
	public static void hideScreen(Screen screen) {
		if (screen == null)
			return;
		synchronized (Application.getEventLock()) {
			if (screen.isDisplayed())
				Ui.getUiEngine().popScreen(screen);
		}
	}

	public static void showScreen(Screen screen) {
		synchronized (Application.getEventLock()) {
			if (screen.isDisplayed())
				return;
			hideScreen(current);
			current = screen;
			Ui.getUiEngine().pushGlobalScreen(screen, 10, UiEngine.GLOBAL_QUEUE);
		}
	}
}
